import {defineStore} from 'pinia'
import request from '@/utils/request'
import {categoryList,ApiRes} from '@/types/data'
import { topCategory } from '@/store/constants'
const defaultCategory = topCategory.map((item) => {
    return {
      name: item,
    }
  })
  const useHomeStore =  defineStore ('category',{
    state:()=>({
        list :defaultCategory as categoryList[]
        
    }),
    actions:{
    async getAllCategory(){
        const res = await request.get<ApiRes<categoryList[]>>('/home/category/head')
       this.list = res.data.result
        
    }

    },
    getters:{}
})
export default useHomeStore